#define _CRT_SECURE_NO_WARNINGS 1

#include <deque>
#include <iostream>
using namespace std;

int main()
{
	deque<int> dq;

	dq.push_back(1);
	dq.push_back(2);
	dq.push_back(3);
	dq.push_back(4);
	dq.push_front(5);
	dq.push_front(6);
	dq.push_front(7);
	dq.push_front(8);

	for (auto q : dq)
	{
		cout << q << " ";
	}
	cout << endl;

	dq.pop_front();
	dq.pop_front();
	dq.pop_back();
	dq.pop_back();
	for (auto q : dq)
	{
		cout << q << " ";
	}
	cout << endl;

	return 0;
}